package com.muyu.system.controller;


import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.system.domain.DanmoMarketProducts;
import com.muyu.system.domain.DanmoMarketTypes;
import com.muyu.system.service.IDanmoMarketTypesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 书画市场类型Controller
 *
 * @author kunzong
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/DanmoMarketTypes")
public class DanmoMarketTypesController extends BaseController {
    @Autowired
    private IDanmoMarketTypesService danmoMarketTypesService;

    /**
     * 查询书画市场类型列表
     */
//    @RequiresPermissions("system:DanmoMarketTypes:list")
    @PostMapping("/list")
    public Result list(DanmoMarketTypes danmoMarketTypes) {
        startPage();
        List<DanmoMarketTypes> list = danmoMarketTypesService.selectDanmoMarketTypesList(danmoMarketTypes);
        PageInfo<DanmoMarketTypes> danmoMarketProductsPageInfo = new PageInfo<>(list);
        return Result.success(danmoMarketProductsPageInfo);
    }

    /**
     * 导出书画市场类型列表
     */
//    @RequiresPermissions("system:DanmoMarketTypes:export")
    @Log(title = "书画市场类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoMarketTypes danmoMarketTypes) {
        List<DanmoMarketTypes> list = danmoMarketTypesService.selectDanmoMarketTypesList(danmoMarketTypes);
        ExcelUtil<DanmoMarketTypes> util = new ExcelUtil<DanmoMarketTypes>(DanmoMarketTypes.class);
        util.exportExcel(response, list, "书画市场类型数据");
    }

    /**
     * 获取书画市场类型详细信息
     */
//    @RequiresPermissions("system:DanmoMarketTypes:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id) {
        return Result.success(danmoMarketTypesService.selectDanmoMarketTypesById(id));
    }

    /**
     * 新增书画市场类型
     */
//    @RequiresPermissions("system:DanmoMarketTypes:add")
    @Log(title = "书画市场类型", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoMarketTypes danmoMarketTypes) {
        return Result.success(danmoMarketTypesService.insertDanmoMarketTypes(danmoMarketTypes));
    }

    /**
     * 修改书画市场类型
     */
//    @RequiresPermissions("system:DanmoMarketTypes:edit")
    @Log(title = "书画市场类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoMarketTypes danmoMarketTypes) {
        return Result.success(danmoMarketTypesService.updateDanmoMarketTypes(danmoMarketTypes));
    }

    /**
     * 删除书画市场类型
     */
//    @RequiresPermissions("system:DanmoMarketTypes:remove")
    @Log(title = "书画市场类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids) {
        return Result.success(danmoMarketTypesService.deleteDanmoMarketTypesByIds(ids));
    }
}
